package com.yc.chatroom.server.dao;

import com.yc.chatroom.server.pojo.po.UserPo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

public interface UserRepositoryDao extends JpaRepository<UserPo, Integer> {

	UserPo findByUserAccount(String userAccount);

	@Modifying
	@Query("update UserPo u set u.userLastLoginTime = :lastLoginTime where u.userId = :userId")
	void updateLastLoginTime(@Param("userId")Integer userId, @Param("lastLoginTime")Long lastLoginTime);
	
	@Transactional
	@Modifying
	@Query("update UserPo u set u.userOnlineStatus =0")
	void updateLoginStatus();
}
